
<template>
  <div class="fastOutput">
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span style="line-height: 36px;">快速出库管理</span>
        <el-button style="float: right; margin-left: 5px" type="primary" @click="dialogOpen('add')">快速出库</el-button>

      </div>
      <s-table
        :table="table"
        @http="tableWatch">
        <el-table-column
          fixed="right"
          align="center"
          slot="operation"
          class-name="operationMore"
          label="可用操作"
          width="120">
          <template slot-scope="s">
            <el-button type="success" size="mini" @click="dialogIssuedOpen(s.row)" v-if="s.row.fyzt==='0'">生成</el-button>
            <el-button type="info" size="mini" icon="search" @click="dialogSearchOpen(s.row)"></el-button>
           </template>
        </el-table-column>
        <el-form-item label="发运编号" prop="fybh">
          <el-input type="text"
                    class="input"
                    v-model="autoVue_table_fybh"
                    placeholder="发运编号" spellcheck="false" auto-capitalize="off" auto-complete="off"
                    auto-correct="off"></el-input>
        </el-form-item>
        <el-form-item label="订单类型" prop="fylx">
          <el-select v-model="autoVue_table_fylx"
                     filterable
                     remote
                     placeholder="请选择订单类型">
            <el-option
              v-for="item in dialog.wmsPurchaseOrder"
              :key="item.id"
              :label="item.ddlx"
              :value="item.id">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="创建时间" prop="cjsj">
          <el-date-picker
            v-model="autoVue_table_cjsj"
            type="daterange"
            placeholder="客户创建时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="货品编号" prop="hpbh">
          <el-input type="text"
                    class="input"
                    v-model="autoVue_table_hpbh"
                    placeholder="货品编号" spellcheck="false" auto-capitalize="off" auto-complete="off"
                    auto-correct="off"></el-input>
        </el-form-item>
        <el-form-item label="货品名称" prop="hpmc">
          <el-input type="text"
                    class="input"
                    v-model="autoVue_table_hpmc"
                    placeholder="货品名称" spellcheck="false" auto-capitalize="off" auto-complete="off"
                    auto-correct="off"></el-input>
        </el-form-item>
        <el-form-item label="省" prop="sheng">
          <el-input type="text"
                    class="input"
                    v-model="autoVue_table_sheng"
                    placeholder="省" spellcheck="false" auto-capitalize="off" auto-complete="off"
                    auto-correct="off"></el-input>
        </el-form-item>
        <el-form-item label="下发状态" prop="fyzt">
          <el-select v-model="autoVue_table_fyzt"
                     placeholder="下发状态">
            <el-option
              label="全部"
              value=""></el-option>
            <el-option
              v-for="item in FASTOUTPUT.fyzt"
              :key="item.dictionaryid"
              :label="item.value"
              :value="item.dictionaryid">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item slot="multiSelect" label="多选操作" prop="multiSelect" v-if="table.multiSelect">
          <el-row>
            <el-col :span="8">
              <el-button size="small"style="float: right;" type="success" @click="tableExport">多选导出</el-button>
            </el-col>
          </el-row>
        </el-form-item>
      </s-table>
    </el-card>
    <s-dialog :dialog="dialog" :close="dialogInit">
      <p slot="title">{{dialog.title}}快速出库</p>
      <el-tabs v-model="dialog.activeName" v-if="dialog.title === '新增'">
        <el-tab-pane label="发运订单表头" name="1" disabled>
          <s-form :form="formDialog" ref="formDialog">
            <el-row>
              <el-col :xs="24" :lg="{span: 7, offset: 0}" class="">
                <el-form-item prop="fybh" label="SO编号">
                  <el-input
                    type="text"
                    v-model="formDialog.fybh"
                    placeholder="SO编号"></el-input>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :lg="{span: 7, offset: 1}" class="">
                <el-form-item prop="yxj" label="优先级">
                  <el-select v-model="formDialog.yxj" placeholder="请选择">
                    <el-option
                      v-for="item in SHIPMENT.yxj"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :lg="{span: 7, offset: 1}" class="">
                <el-form-item prop="khid" label="客户编号">
                  <el-select v-model="formDialog.khid"
                             filterable
                             remote
                             placeholder="请选择客户编号"
                             @change="dialogRemoteKhbhid"
                             :remote-method="dialogRemoteKhbh">
                    <el-option
                      v-for="item in dialog.wmsshipmentorder"
                      :key="item.id"
                      :label="item.khbh + '  ' + item.khmc"
                      :value="item.id">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :xs="24" :lg="{span: 23, offset: 0}">
                <el-collapse v-model="dialog.activeNameCollapse" accordion v-if="formDialog.khid">
                  <el-collapse-item title="客户详情" name="1">
                    <el-row>
                      <el-col :xs="24" :lg="{span: 7, offset: 0}" class="">
                        <el-form-item prop="khmc" label="客户名称">
                          <el-input
                            type="text"
                            disabled
                            v-model="formDialog.khmc"
                            placeholder="客户名称"></el-input>
                        </el-form-item>
                      </el-col>
                      <!--<el-col :xs="24" :lg="{span: 7, offset: 1}" class="">-->
                      <!--<el-form-item prop="xlmc" label="路线名称">-->
                      <!--<el-input-->
                      <!--type="text"-->
                      <!--disabled-->
                      <!--v-model="formDialog.xlmc"-->
                      <!--placeholder="路线名称"></el-input>-->
                      <!--</el-form-item>-->
                      <!--</el-col>-->
                      <el-col :xs="24" :lg="{span: 7, offset: 1}" class="">
                        <el-form-item prop="lxrdh" label="联系电话">
                          <el-input
                            type="text"
                            disabled
                            v-model="formDialog.lxrdh"
                            placeholder="联系电话"></el-input>
                        </el-form-item>
                      </el-col>
                      <el-col :xs="24" :lg="{span: 7, offset: 1}" class="">
                        <el-form-item prop="lxrxm" label="联系人姓名">
                          <el-input
                            type="text"
                            disabled
                            v-model="formDialog.lxrxm"
                            placeholder="联系人姓名"></el-input>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row>
                      <el-col :xs="24" :lg="{span: 8, offset: 0}" class="">
                        <el-form-item prop="khdz" label="客户地址">
                          <el-input
                            type="text"
                            disabled
                            v-model="formDialog.khdz"
                            placeholder="客户地址"></el-input>
                        </el-form-item>
                      </el-col>
                      <el-col :xs="24" :lg="{span: 5, offset: 1}" class="">
                        <el-form-item prop="sheng" label="省">
                          <el-input
                            type="text"
                            disabled
                            v-model="formDialog.sheng"
                            placeholder="省"></el-input>
                        </el-form-item>
                      </el-col>
                      <el-col :xs="24" :lg="{span: 5, offset: 1}" class="">
                        <el-form-item prop="shi" label="市">
                          <el-input
                            type="text"
                            disabled
                            v-model="formDialog.shi"
                            placeholder="shi"></el-input>
                        </el-form-item>
                      </el-col>
                    </el-row>
                  </el-collapse-item>
                </el-collapse>
              </el-col>
            </el-row>
            <el-row>
              <el-col :xs="24" :lg="{span: 7, offset: 0}" class="">
                <el-form-item prop="fylx" label="订单类型">
                  <el-select v-model="formDialog.fylx"
                             filterable
                             remote
                             placeholder="请选择订单类型"
                             :remote-method="dialogRemoteDdlx">
                    <el-option
                      v-for="item in dialog.wmsPurchaseOrder"
                      :key="item.id"
                      :label="item.ddlx"
                      :value="item.id">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :lg="{span: 15, offset: 1}" class="">
                <el-form-item prop="bz" label="备注">
                  <el-input
                    type="textarea"
                    v-model="formDialog.bz"
                    placeholder="备注"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </s-form>
        </el-tab-pane>
        <el-tab-pane label="发运订单明细" name="2" disabled>
          <div class="__table" v-if="this.dialog.title === '新增'">
            <el-button @click="dialogAddMxOpen('add')" class="__table_button"><i class="el-icon-plus"></i></el-button>
          </div>
          <s-table
            :table="tableAdd" ref="tableAdd" @http="tableWatch" :control="false" v-if="this.dialog.title === '新增'">
            <el-table-column
              fixed="right"
              align="center"
              slot="operation"
              class-name="operationMore"
              label="可用操作"
              width="120">
              <template slot-scope="s">
                <!--<el-button type="info" size="mini" icon="edit" @click="dialogAddEditOpen(s.row)"></el-button>-->
                <el-button type="danger" icon="delete" size="mini" @click="tableAddDelete(s.$index)"></el-button>
              </template>
            </el-table-column>
          </s-table>
        </el-tab-pane>
      </el-tabs>
      <el-button slot="footer" v-if="dialog.activeName !== '1'" @click="dialogPre">上一页</el-button>
      <el-button slot="footer" type="info" v-if="dialog.activeName !== '2'" @click="dialogNext">下一页</el-button>
      <el-button slot="footer" type="success" v-if="dialog.activeName === '2'" @click="dialogSave">保存</el-button>
    </s-dialog>
    <s-dialog :dialog="dialogAddMx" :close="dialogAddMxInit">
      <p slot="title">{{dialogAddMx.title}}快速出库明细</p>
      <s-table :table="tableAddMx" ref="tableAddMx" @http="tableWatch" :multiSelect="true" >
        <!--<el-table-column-->
          <!--fixed="right"-->
          <!--align="center"-->
          <!--slot="operation"-->
          <!--class-name="operationMore"-->
          <!--label="操作"-->
          <!--width="80">-->
          <!--<template slot-scope="s">-->
            <!--<el-button type="info" size="mini" @click="dialogLocationOpen(s.row)">选择</el-button>-->
          <!--</template>-->
        <!--</el-table-column>-->
        <el-form-item label="货品编号" prop="hpbh">
          <el-input type="text"
                    class="input"
                    v-model="autoVue_tableAddMx_hpbh"
                    placeholder="货品编号" spellcheck="false" auto-capitalize="off" auto-complete="off"
                    auto-correct="off"></el-input>
        </el-form-item>
        <el-form-item label="货品名称" prop="hpmc">
          <el-input type="text"
                    class="input"
                    v-model="autoVue_tableAddMx_hpmc"
                    placeholder="货品名称" spellcheck="false" auto-capitalize="off" auto-complete="off"
                    auto-correct="off"></el-input>
        </el-form-item>
        <el-form-item label="货品批次" prop="hpph">
          <el-input type="text"
                    class="input"
                    v-model="autoVue_tableAddMx_hpph"
                    placeholder="货品批次" spellcheck="false" auto-capitalize="off" auto-complete="off"
                    auto-correct="off"></el-input>
        </el-form-item>
        <!--<el-form-item label="库位名称" prop="show_kwid">-->
        <!--<el-input type="text"-->
        <!--class="input"-->
        <!--v-model="autoVue_tableAddMx_show_kwid"-->
        <!--placeholder="库位名称" spellcheck="false" auto-capitalize="off" auto-complete="off"-->
        <!--auto-correct="off"></el-input>-->
        <!--</el-form-item>-->
        <el-form-item label="生产日期" prop="hpscrq">
          <el-date-picker
            v-model="autoVue_tableAddMx_hpscrq"
            type="daterange"
            placeholder="选择日期范围">
          </el-date-picker>
        </el-form-item>
      </s-table>
      <el-button slot="footer" @click="dialogAddMxSave">保存</el-button>
    </s-dialog>
    <s-dialog :dialog="dialogSearch" :close="dialogSearchInit">
      <p slot="title">查看明细<span>{{dialogSearch.row.bh}}</span></p>
      <div class="__table">
        <el-button @click="dialogSearchMxOpen('add')" v-if="dialogSearch.row.fyzt =='0'"
                   class="__table_button"><i class="el-icon-plus"></i></el-button>
        <s-table :table="tableSearch" ref="tableSearch" @http="tableWatch" :control="dialogSearch.row.fyzt !=='0'" :pagination="false" >
          <el-table-column
            fixed="right"
            align="center"
            slot="operation"
            class-name="operationMore"
            label="操作"
            width="180">
            <template slot-scope="s">
              <el-button type="danger" icon="delete" size="mini" @click="tableSearchDelete(s.row)"></el-button>
            </template>
          </el-table-column>
        </s-table>
      </div>
    </s-dialog>
    <s-dialog :dialog="dialogSearchMx" :close="dialogSearchMxInit">
      <p slot="title">{{dialogSearchMx.title}}快速出库明细</p>
      <s-table :table="tableSearchMx" ref="tableSearchMx" @http="tableWatch" :multiSelect="true" >
        <!--<el-table-column-->
        <!--fixed="right"-->
        <!--align="center"-->
        <!--slot="operation"-->
        <!--class-name="operationMore"-->
        <!--label="操作"-->
        <!--width="80">-->
        <!--<template slot-scope="s">-->
        <!--<el-button type="info" size="mini" @click="dialogLocationOpen(s.row)">选择</el-button>-->
        <!--</template>-->
        <!--</el-table-column>-->
        <el-form-item label="货品编号" prop="hpbh">
          <el-input type="text"
                    class="input"
                    v-model="autoVue_tableAddMx_hpbh"
                    placeholder="货品编号" spellcheck="false" auto-capitalize="off" auto-complete="off"
                    auto-correct="off"></el-input>
        </el-form-item>
        <el-form-item label="货品名称" prop="hpmc">
          <el-input type="text"
                    class="input"
                    v-model="autoVue_tableAddMx_hpmc"
                    placeholder="货品名称" spellcheck="false" auto-capitalize="off" auto-complete="off"
                    auto-correct="off"></el-input>
        </el-form-item>
        <el-form-item label="货品批次" prop="hpph">
          <el-input type="text"
                    class="input"
                    v-model="autoVue_tableAddMx_hpph"
                    placeholder="货品批次" spellcheck="false" auto-capitalize="off" auto-complete="off"
                    auto-correct="off"></el-input>
        </el-form-item>
        <!--<el-form-item label="库位名称" prop="show_kwid">-->
        <!--<el-input type="text"-->
        <!--class="input"-->
        <!--v-model="autoVue_tableAddMx_show_kwid"-->
        <!--placeholder="库位名称" spellcheck="false" auto-capitalize="off" auto-complete="off"-->
        <!--auto-correct="off"></el-input>-->
        <!--</el-form-item>-->
        <el-form-item label="生产日期" prop="hpscrq">
          <el-date-picker
            v-model="autoVue_tableAddMx_hpscrq"
            type="daterange"
            placeholder="选择日期范围">
          </el-date-picker>
        </el-form-item>
      </s-table>
      <el-button slot="footer" @click="dialogSearchMxSave">保存</el-button>
    </s-dialog>
    <!--新增收货任务-->
    <s-dialog :dialog="dialogIssued" :close="formDalogInit">
      <p slot="title">{{dialogIssued.title}}检货任务</p>
      <s-form :form="formDalogIssued" ref="formDalogIssued">
        <el-row>
          <el-col :xs="24" :lg="{span: 11, offset: 0}" class="">
            <el-form-item prop="account" label="账户类型">
              <el-select v-model="formDalogIssued.account" placeholder="请选择">
                <el-option
                  v-for="item in SHELVESTASK.account"
                  :key="item.dictionaryid"
                  :label="item.value"
                  :value="item.dictionaryid">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :lg="{span: 11, offset: 1}" class="">
            <el-form-item prop="ids" label="人员">
              <el-select v-model="formDalogIssued.ryid"
                         filterable
                         @change="formDalogIssuedid"
                         placeholder="请输入人员名称">
                <el-option
                  v-for="item in dialogIssued.wmsqualityinspectionlist"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </s-form>
      <el-button slot="footer" @click="dialogIssuedSave">保存</el-button>
    </s-dialog>
  </div>
</template>

<script>
  import {AutoVue, AutoPromise} from '~/plugins/Tools';
  import {China} from '~/config';

  function __form () {
    return {
      khid: { value: '', rule: [ 'vNull__change' ], cRemarks: '' },
      zyf: { value: '', rule: [ ], cRemarks: '' },
      khddh: { value: '', rule: [], cRemarks: '' },
      ...__form_kh(),
      fybh: { value: '1', rule: [ 'vNull' ], cRemarks: '' },
      fylx: { value: '', rule: [ 'vNull__change' ], cRemarks: '' },
      yxj:
        { value: 1,
          rule: [ 'vNull__change' ],
          cRemarks: '1、1， 2、2，3、3,4、4,5、5' },
      bz: { value: '', rule: [ '' ], cRemarks: '' },
      cjsj: { value: '', rule: [ 'vNull' ], cRemarks: '' },
      jhfhsj: { value: '', rule: [ 'vNull' ], cRemarks: '', type: 'Date' },
      yqjhsj: { value: '', rule: [ 'vNull' ], cRemarks: '', type: 'Date' },
      jhfs: { value: '0', rule: [ 'vNull__change' ], cRemarks: '0：发运 1：自提' },
      china:
        { value: [],
          rule: [ 'vNullArray2__change' ] },
    };
  }
  function __form_kh () {
    return {
      khbh: { value: '', rule: [], cRemarks: '' },
      khmc: { value: '', rule: [], cRemarks: '' },
      khdz: { value: '', rule: [], cRemarks: '' },
      xlmc: { value: '', rule: [], cRemarks: '' },
      lxrxm: { value: '', rule: [], cRemarks: '' },
      lxrdh: { value: '', rule: [], cRemarks: '' },
      sheng: { value: '', rule: [], cRemarks: '' },
      shi: { value: '', rule: [], cRemarks: '' },
    };
  }
  function __formIssued () {
    return {
      account: { value: '', rule: [ 'vNull__change' ], cRemarks: '' },
      ryid: { value: [], rule: ['vNull__change'], cRemarks: [] },
      ids: { value: [], rule: [], cRemarks: [] },

    };
  }
  export default AutoVue({
    name: 'outOperation_fastOutput-FEcarWms',
    head: {
      'title': '快速出库管理',
      'meta': [
        { 'hid': 'description', 'name': 'description', 'content': '乐速科技平台 快速出库 查看快速出库信息' },
      ],
    },
    store: ['DICTIONARY_shipment', 'SHIPMENT', 'CUSTOMERFILE', 'SHELVESTASK', 'DICTIONARY_shelvestask', 'DICTIONARY_fastOutput', 'FASTOUTPUT'],
    data: {
      table: {
        column: [
          { label: '发运编号',
            prop: 'fybh',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '发运类型',
            prop: 'show_fylx',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '优先级',
            prop: 'yxj',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '下发状态',
            prop: 'show_fyzt',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '创建时间',
            prop: 'cjsj',
            minWidth: '0px',
            cRemarks: '',
            formatter: (row, column) => {
              return this.a.methods.formatterTime(row[column.property || column], 6);
            },
            type: 'DateRange',
            search: true },
          { label: '联系人姓名',
            prop: 'lxrxm',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '联系人电话',
            prop: 'lxrdh',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '省',
            prop: 'sheng',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '市',
            prop: 'sh',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '客户地址',
            prop: 'khdz',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '货品名称',
            prop: 'hpmc',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '货品编号',
            prop: 'hpbh',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '备注',
            prop: 'bz',
            minWidth: '0px',
            cRemarks: '',
            search: true },
        ],
        url: '/wmsquickexit/list',
        key: 'id',
        tableColumn: 5,
      },
      formDialog: __form(),
      dialog: {
        title: '新增',
        row: {},
        id: [],
        activeName: '1',
        activeNameCollapse: '1',
        wmsPurchaseOrder: [],
        wmsshipmentorder: [],
        size: 'large',
      },

      tableAdd: {
        column:
          [ { label: '货品编号',
            prop: 'hpbh',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '货品名称',
            prop: 'hpmc',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '单位描述',
            prop: 'dwms',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '货品批次',
            prop: 'hpph',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '生产日期',
            prop: 'hpscrq',
            minWidth: '0px',
            cRemarks: '',
            formatter: (row, column) => {
              return this.a.methods.formatterTime(row[column.property || column], 3);
            },
            search: true },
          { label: '库位 ',
            prop: 'show_kwid',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '出库数量',
            prop: 'zysl',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '出库数量',
            prop: 'kcsl',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          ],
        url: '/wmsshipmentorder/getShipmentOrder',
        key: 'id',
        tableColumn: 7,
      },

      dialogAddMx: {
        title: '新增',
        size: 'large',
      },
      tableAddMx: {
        column:
          [ { label: '货品编号',
            prop: 'hpbh',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '货品名称',
            prop: 'hpmc',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '货品批次',
            prop: 'hpph',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '生产日期',
            prop: 'hpscrq',
            minWidth: '0px',
            cRemarks: '',
            type: 'DateRange',
            formatter: (row, column) => {
              return this.a.methods.formatterTime(row[column.property || column], 3);
            },
            search: true },
          { label: '单位描述',
            prop: 'dwms',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '库存数量',
            prop: 'kydsl',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '库位',
            prop: 'show_kwid',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '出库数量',
            prop: 'zysl',
            minWidth: '0px',
            cRemarks: '',
            elInputNumber: {
              min: 1,
              controls: [false, true],
              max: 'kydsl',
            },
            search: false },
          ],
        url: '/wmsquickexitdetailed/searchKc',
        tableColumn: 8,
        key: 'hpkcid',
        muti: false,
      },
      dialogLocation: {
        title: '选择',
        wmsstockmove: [],
        row: {},
        show_ydhkwid: '',
      },
      dialogSearch: {
        row: {},
        size: 'large',
      },
      tableSearch: {
        column: [
          { label: '货品编号',
            prop: 'hpbh',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '货品名称',
            prop: 'hpmc',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '库位名称',
            prop: 'kwmc',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '货品批次',
            prop: 'hppc',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '生产日期',
            prop: 'scrq',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '规格',
            prop: 'gg',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: 'NC编码',
            prop: 'nc',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '主单位数量',
            prop: 'sl',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '主单位名称',
            prop: 'zdwmc',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '箱单位名称',
            prop: 'xdwmc',
            minWidth: '0px',
            cRemarks: '',
            search: true },
        ],
        key: 'id',
        tableColumn: 8,
        muti: false,
      },
      dialogSearchMx: {
        title: '新增',
        size: 'large',
      },
      tableSearchMx: {
        column:
          [ { label: '货品编号',
            prop: 'hpbh',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '货品名称',
            prop: 'hpmc',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '货品批次',
            prop: 'hpph',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '生产日期',
            prop: 'hpscrq',
            minWidth: '0px',
            cRemarks: '',
            type: 'DateRange',
            formatter: (row, column) => {
              return this.a.methods.formatterTime(row[column.property || column], 3);
            },
            search: true },
          { label: '单位描述',
            prop: 'dwms',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '出库数量',
            prop: 'kcsl',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '库位',
            prop: 'show_kwid',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '出库数量',
            prop: 'zysl',
            minWidth: '0px',
            cRemarks: '',
            elInputNumber: {
              min: 1,
              controls: [false, true],
              max: 'kydsl',
            },
            search: false },
          ],
        url: '/wmsquickexitdetailed/searchKc',
        tableColumn: 8,
        key: 'hpkcid',
        muti: false,
      },
      formDalogIssued: __formIssued(),
      dialogIssued: {
        id: '',
        activeName: '1',
        activeNameCollapse: '1',
        wmsPurchaseOrder: [],
        wmsshipmentorder: [],
        size: 'large',
        title: '下发',
        // ryid: [],
        wmsqualityinspectionlist: '',
        // ids: [],
        row: {},
      },
    },
    transition: 'slide-fade',
    methods: {
      // 导出
      tableExport () {
        let tableRef = 'table';
        let ids = [];
        this.table.multipleSelection.forEach(item => {
          ids.push(item.id);
        });
        this.$confirm('您将导出快速出库的信息', '确认导出？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(async _ => {
            try {
              let option = Object.assign({}, this['autoVue_' + tableRef]);
              await this.p({
                url: 'wmsquickexit/exportDetail',
                method: 'post',
                responseType: 'blob',
                data: {
                  ids,
                  ...option,
                },
              });
            } catch (err) {
              console.log(err);
            }
          });
      },
      dialogInit () {
        this.dialog.activeName = '1';
        this.dialog.activeNameCollapse = '1';
        this.formDialog = {
          ...this.formDialog,
          ...this.ObjectClone(__form()),
        };
        this.tableClear('tableAdd');
        this.resetFields('formDialog');
      },
      formDalogInit () {
        this.formDalogIssued = {
          ...this.formDalogIssued,
          ...this.ObjectClone(__form()),
        };
        console.log('formDalogIssued');
        this.resetFields('formDalogIssued');
      },
      // 弹出  生成
      async dialogIssuedOpen (row) {
        await AutoPromise([
          async () => {
            if (!this.DICTIONARY_shelvesTask) {
              await this.USE('DICTIONARY_shelvesTask');
            }
          },
        ]);
        this.dialogIssued.row = row;
        this.dialogIssued.visible = true;
      },
      async formDalogIssuedid (id) {
        this.dialogIssued.wmsqualityinspectionlist.forEach(value => {
          console.log(value.id);
          console.log(id);
          if (id === value.id) {
            this.dialogIssued.row.userName = value.name;
            this.dialogIssued.row.ryid = value.id;
          }
        });
      },
      // 下发货 保存
      dialogIssuedSave () {
        // let shuzu = [];
        if (this.formDalogIssued.account === '0') {
          this.VALIDATE('formDalogIssued', async option => {
            option.id = this.dialogIssued.row.id;
            option.ryid = this.formDalogIssued.ryid;
            option.fyzt = this.formDalogIssued.fyzt;
            // 转数组
            // var s = option.ids;
            // console.log(s);
            // delete option.account;
            // delete option.ryid;
            // console.log('option:' + option);
            // JSON.stringify(option);
            try {
              await this.get('/wmsquickexit/getXf/' + option.id + '/' + option.ryid);
              this.tableWatch('table');
              this.formDalogInit();
              this.dialogIssued.visible = false;
            } catch (err) {
              console.log(err);
            }
          });
        } else {
          this.VALIDATE('formDalogIssued', async option => {
            option.id = this.dialogIssued.row.id;
            option.ryid = this.formDalogIssued.ryid;
            option.fyzt = this.formDalogIssued.fyzt;
            delete option.account;
            // delete option.ryid;
            try {
              await this.get('/wmsquickexit/getXf/' + option.id + '/' + option.ryid);
              this.tableWatch('table');
              this.formDalogInit();
              this.dialogIssued.visible = false;
            } catch (err) {
              console.log(err);
            }
          });
        }
      },
      async dialogOpen (type, row) {
        if (type) {
          type = type.toUpperCase();
        } else return;
        switch (type) {
        case 'ADD':
          await AutoPromise([
            async () => {
              await this.dialogRemoteKhbh('');
            },
            async () => {
              await this.dialogRemoteDdlx('');
            },
            async () => {
              let {bh} = await this.get('/wmsshipmentorder/getBh');
              this.formDialog.fybh = bh;
            },
          ]);
          this.dialog.title = '新增';
          this.dialog.row = row;
          break;
        }
        this.dialog.visible = true;
      },
      async dialogRemoteDdlx (query) {
        this.dialog.wmsPurchaseOrder = await this.post('/wmsshipmentorder/getPoLx', {ddlx: query});
      },
      dialogPre () {
        this.dialog.activeName = parseInt(this.dialog.activeName) - 1 + '';
      },
      dialogNext () {
        this.VALIDATE('formDialog', optopn => {
          this.dialog.activeName = parseInt(this.dialog.activeName) + 1 + '';
        });
        /*
        this.VALIDATE('formDialog' + this.dialog.activeName, option => {
          this.dialog.activeName = parseInt(this.dialog.activeName) + 1 + '';
          alert('aaa');
        });
        */
        /*
        switch (this.dialog.activeName) {
        case '2':
          if (this.tableAdd.data.length !== 0) {
            // this.dialog.activeName = '2';
          } else {
            this.$alert('列表信息不能为空!', '提示');
          }
          break;
        default :this.VALIDATE('formDialog' + this.dialog.activeName, option => {
          this.dialog.activeName = parseInt(this.dialog.activeName) + 1 + '';
        });
        }
        */
      },
      async dialogRemoteKhbh (query) {
        this.dialog.wmsshipmentorder = await this.post('/wmsshipmentorder/getCusInfo', {khbh: query});
      },
      dialogRemoteKhbhid (id) {
        this.dialog.wmsshipmentorder.forEach(value => {
          if (value.id === id) {
            this.formDialog = {
              ...this.formDialog,
              ...this.ObjectClone(__form_kh(), value),
            };
            this.dialog.sheng = value.sheng;
            this.dialog.shi = value.shi;
            this.dialog.khdz = value.khdz;
            this.dialog.lxrdh = value.lxrdh;
            this.dialog.lxrxm = value.lxrxm;
          }
        });
      },
      dialogSave () {
        if (this.dialog.title === '新增') {
          this.VALIDATE('formDialog', async option => {
            let json = {
              wmsQuickExitDetailedList: this.tableAdd.data,
              ...option,
            };
            try {
              console.log('hpkcid:' + json.hpkcid);
              console.log('json:' + json);
              await this.post('/wmsquickexit/add', json);
              this.tableWatch('table');
              this.dialogInit();
              this.dialog.visible = false;
            } catch (err) {
              console.log(err);
            }
          });
        }
      },

      dialogAddMxInit () {
        this.tableClear('tableAddMx');
      },
      dialogAddMxOpen () {
        if (this.dialogAddMx.title === '新增') {
          this.tableAddMx.url = '/wmsquickexitdetailed/searchKc';
          this.tableWatch('tableAddMx');
        }
        this.dialogAddMx.visible = true;
      },
      dialogAddMxSave () {
        if (this.dialogAddMx.title === '新增') {
          if (this.tableAddMx.multipleSelection.length < 1) {
            this.$alert('请至少选择1条货品信息', '提示');
          } else {
            let bool = true;
            if (bool) {
              this.tableAddMx.multipleSelection.forEach(item => {
                this.tableAdd.data.push(item);
                this.dialogAddMxInit();
                this.dialogAddMx.visible = false;
              });
            }
          }
        };
      },
      tableAddDelete (index) {
        this.$confirm('您将删除选择的明细:', '确认删除？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(_ => {
            this.tableAdd.data.splice(index, 1);
          });
      },

      dialogSearchInit () {
      },
      async dialogSearchOpen (row) {
        this.dialogSearch.row = row;
        try {
          let {contentList} = await this.get('/wmsquickexitdetailed/list/' + row.id);
          this.tableSearch.data = contentList;
          this.tableSearch.total = contentList.length;
          this.dialogSearch.visible = true;
        } catch (err) {
          console.error(err);
        }
        /*
        try {
          this.dialogSearch.row = row;
          this.tableWatch('tableSearch');
        } catch (err) {
          console.log(err);
        }
        */
      },

      tableSearchDelete (row) {
        let ids = [];
        if (row) {
          ids.push(row.id);
        } else {
          if (this.table.multipleSelection.length < 1) {
            return this.$alert('您还未选择，请您至少选择一个！', '提示');
          }
          this.table.multipleSelection.forEach(item => {
            ids.push(item.id);
          });
        }
        this.$confirm('您将删除选择的数据', '确认删除？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(async _ => {
            try {
              await this.post('/wmsquickexitdetailed/del', {
                ids,
              });
              this.tableWatch('table');
            } catch (err) {
              console.log(err);
            }
          })
          .catch(_ => {
          });
      },
      dialogSearchMxInit () {
        this.tableClear('tableSearchMx');
      },
      dialogSearchMxOpen () {
        this.tableWatch('tableSearchMx');
        this.dialogSearchMx.visible = true;
      },
      async dialogSearchMxSave () {
        if (this.tableSearchMx.multipleSelection.length < 1) {
          return this.$alert('请至少选择一个', '提示');
        } else {
          let bool = true;
          /*
          this.tableSearchMx.multipleSelection.forEach(item => {
            this.tableSearch.data.forEach((value, index) => {
              if (item.hpbh === value.hpbh) {
                this.$alert('已经存在：' + '货品：' + value.hpbh, '提示');
                this.dialogSearchMx.visible = true;
                bool = false;
              }
            });
          });
          */
          if (bool) {
            try {
              this.tableSearchMx.multipleSelection.forEach(item => {
                item.ksckid = this.dialogSearch.row.id;
                console.log('ksckid:' + this.dialogSearch.row.id);
              });
              await this.post('/wmsquickexitdetailed/add', this.tableSearchMx.multipleSelection);
              this.dialogSearchMxInit();
              try {
                let {contentList} = await this.get('/wmsquickexitdetailed/list/' + this.dialogSearch.row.id);
                this.tableSearch.data = contentList;
                this.tableSearch.total = contentList.length;
              } catch (err) {
                console.error(err);
              }
              this.dialogSearchMx.visible = false;
            } catch (err) {
              console.log(err);
            }
          }
        }
      },
    },
    // 选择账户类型
    watch: {
      'formDalogIssued.account': async function (account) {
        this.formDalogIssued.arr = '';
        if (account.length !== 0 && account === '0') {
          this.dialogIssued.wmsqualityinspectionlist = await this.post('/wmsqualityinspectionlist/selectYh', {});
        }
        if (account.length !== 0 && account === '1') {
          let {contentList} = await this.post('/wmsqualityinspectionlist/selectPDADLByHz', {});
          this.dialogIssued.wmsqualityinspectionlist = contentList;
        }
      },
    },
    mounted: async function () {
      await AutoPromise([
        async () => {
          if (this.dialog.wmsPurchaseOrder.length === 0) {
            this.dialog.wmsPurchaseOrder = await this.post('/wmsshipmentorder/getPoLx', {
            });
          }
        },
        async () => {
          if (!this.DICTIONARY_fastOutput) {
            await this.USE('DICTIONARY_fastOutput');
          }
        },
      ]);
      this.tableWatch('table');
    },
    fetch (context) {
      let { store } = context;
      store.commit('CUSTOMERFILE/SET', China);
    },
  });
</script>
<style scoped lang="scss">
  .box-card {
    margin: 20px;
  }

  .createTimeSpan {
    display: block;
    margin-top: 34px;
  }

  @media screen and (max-width: 800px) {
    .createTimeSpan {
      margin-top: 0;
    }
    .box-card {
      margin: 0;
    }
  }

  .el-select {
    width: 100%;
  }
</style>

<style lang="scss">
</style>
